package com.leyou.search.constants;

public abstract class SearchConstants {

    /**
     * 自动补全的模板id
     */
    public static final String SUGGESTION_TEMPLATE_ID = "goods_suggest_template";
    /**
     * 自动补全的模板参数1名称
     */
    public static final String SUGGESTION_PARAM_PREFIX_KEY = "prefix_key";
    /**
     * 自动补全的模板参数2名称
     */
    public static final String SUGGESTION_PARAM_FIELD = "suggest_field";
    /**
     * 自动补全的自动名
     */
    public static final String SUGGESTION_FIELD = "suggestion";

    /**
     * 默认的查询字段
     */
    public static final String SEARCH_FIELD = "title";

    /**
     * 默认查询的source字段
     */
    public static final String[] SOURCE_FIELD = new String[]{"id", "title", "image", "prices", "sold"};

    /**
     * 分类字段名称
     */
    public static final String CATEGORY_FIELD_NAME = "categoryId";
    /**
     * 品牌字段名称
     */
    public static final String BRAND_FIELD_NAME = "brandId";
    /**
     * 规格参数字段路径
     */
    public static final String SPEC_FIELD_PATH = "specs";

    /**
     * 规格参数名称字段的name
     */
    public static final String SPEC_NAME_FIELD_NAME = "specs.name";
    /**
     * 规格参数值字段路径name
     */
    public static final String SPEC_VALUE_FIELD_NAME = "specs.value";
    /**
     * 映射模板
     */
    public static final String INDEX_SOURCE = "{\n" +
            "  \"settings\": {\n" +
            "    \"analysis\": {\n" +
            "      \"analyzer\": {\n" +
            "        \"my_pinyin\": {\n" +
            "          \"tokenizer\": \"ik_max_word\",\n" +
            "          \"filter\": [\n" +
            "            \"py\"\n" +
            "          ]\n" +
            "        }\n" +
            "      },\n" +
            "      \"filter\": {\n" +
            "        \"py\": {\n" +
            "\t\t  \"type\": \"pinyin\",\n" +
            "          \"keep_full_pinyin\": false,\n" +
            "          \"keep_joined_full_pinyin\": true,\n" +
            "          \"keep_original\": true,\n" +
            "          \"limit_first_letter_length\": 16,\n" +
            "          \"remove_duplicated_term\": true,\n" +
            "          \"none_chinese_pinyin_tokenize\": false\n" +
            "        }\n" +
            "      }\n" +
            "    }\n" +
            "  },\n" +
            "  \"mappings\": {\n" +
            "    \"properties\": {\n" +
            "      \"id\": {\n" +
            "        \"type\": \"keyword\"\n" +
            "      },\n" +
            "      \"suggestion\": {\n" +
            "        \"type\": \"completion\",\n" +
            "        \"analyzer\": \"my_pinyin\",\n" +
            "        \"search_analyzer\": \"ik_smart\"\n" +
            "      },\n" +
            "      \"title\":{\n" +
            "        \"type\": \"text\",\n" +
            "        \"analyzer\": \"my_pinyin\",\n" +
            "        \"search_analyzer\": \"ik_smart\"\n" +
            "      },\n" +
            "      \"image\":{\n" +
            "        \"type\": \"keyword\",\n" +
            "        \"index\": false\n" +
            "      },\n" +
            "      \"updateTime\":{\n" +
            "        \"type\": \"date\"\n" +
            "      },\n" +
            "      \"specs\":{\n" +
            "        \"type\": \"nested\",\n" +
            "        \"properties\": {\n" +
            "          \"name\":{\"type\": \"keyword\" },\n" +
            "          \"value\":{\"type\": \"keyword\" }\n" +
            "        }\n" +
            "      }\n" +
            "    }\n" +
            "  }\n" +
            "}";
}
